package ai.esc.speedy.admin.user.infrastructure.shiro;

import ai.esc.speedy.admin.user.infrastructure.jwt.JwtToken;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
import org.springframework.stereotype.Component;

/**
 * @author Rubin
 * @version v1 2020/2/28 13:52
 */
@Component
public class CredentialsMatcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        JwtToken utoken = (JwtToken) token;

        //获得用户输入的密码:(可以采用加盐(salt)的方式去检验)


        //获得数据库中的密码
        String dbPassword = (String) info.getCredentials();
        SimpleAuthenticationInfo saInfo = (SimpleAuthenticationInfo) info;

        //进行密码的比对
        return true;
    }

}
